package pers.leeyns.rd.email;

import pers.leeyns.rd.base.RandomStringGenerator;

/**
 * @description Emial 随机生成器
 * @author Leeyns
 * @date 2016年2月16日
 */
public class RandomEmailGenerator extends RandomStringGenerator{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1461973693854997730L;

	/**
	 * Email model
	 */
	private static final String[] EMAIL_SUFFIX="@gmail.com,@yahoo.com,@msn.com,@hotmail.com,@aol.com,@ask.com,@live.com,@qq.com,@0355.net,@163.com,@163.net,@263.net,@3721.net,@yeah.net,@googlemail.com,@126.com,@sina.com,@sohu.com,@yahoo.com.cn".split(",");
	
	public static synchronized RandomEmailGenerator build(){
		return new RandomEmailGenerator();
	}
	

	/**
	 * 随机生成邮件地址
	 * @param emailModel 邮件后缀（网址）
	 * @param length
	 * @return
	 */
	public String getRandomEmailAddress(String[] emaiEndFixlModel,int length){
		if(emaiEndFixlModel == null) {
			emaiEndFixlModel = EMAIL_SUFFIX;
		}
		return getRandomString(length) + emaiEndFixlModel[nextInt(emaiEndFixlModel.length)];
	}
	
	/**
	 * 随机生成Email
	 * @param length
	 * @return
	 */
	public  String getRandomEmailAddress(int length){
		return getRandomEmailAddress(EMAIL_SUFFIX, length);
	}
	
	public static void main(String[] args) {
		while(true){
			System.out.println(RandomEmailGenerator.build().getRandomEmailAddress(8).toLowerCase());
		}
	}
}
